﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using CTTest.Essential;
using CTTest.Essential.Soap.BMS;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CTTest
{
    /// <summary>
    /// 9.1.1 用户登录/注销接口
    /// </summary>
    public partial class CTTestMain
    {
        private static readonly string 有效号码 = "18912345678";
        private static readonly string 无效号码 = Guid.NewGuid().ToString();
        private static readonly string 登录代码 = "Login";
        private static readonly string 注销代码 = "Logout";

        [TestMethod]
        [Description("用户登录--正常登录场景测试")]
        public void 用户登录の正常登录场景()
        {
            WriteLogger("Entering test method {0}", MethodBase.GetCurrentMethod().Name);

            var flag = CtcUtil.TestLogin(new LoginReq
            {
                UserID = 有效号码,
                Action = 登录代码,
            }, WriteLogger);
            Assert.IsTrue(flag, "用户登录失败");

            WriteLogger("Leaving test method {0}", MethodBase.GetCurrentMethod().Name);
        }

        [TestMethod]
        [Description("用户登录--无效号码登录场景测试")]
        public void 用户登录の无效号码登录场景()
        {
            WriteLogger("Entering test method {0}", MethodBase.GetCurrentMethod().Name);

            var flag = CtcUtil.TestLogin(new LoginReq
            {
                UserID = 无效号码,
                Action = 登录代码,
            }, WriteLogger);
            Assert.IsFalse(flag, "无效号码用户登录成功！");

            WriteLogger("Leaving test method {0}", MethodBase.GetCurrentMethod().Name);
        }


        [TestMethod]
        [Description("用户登录--正常注销场景测试")]
        public void 用户登录の正常注销场景()
        {
            WriteLogger("Entering test method {0}", MethodBase.GetCurrentMethod().Name);

            var flag = CtcUtil.TestLogin(new LoginReq
            {
                UserID = 有效号码,
                Action = 注销代码,
            }, WriteLogger);
            Assert.IsTrue(flag, "用户注销失败");

            WriteLogger("Leaving test method {0}", MethodBase.GetCurrentMethod().Name);
        }

        [TestMethod]
        [Description("用户登录--无效号码注销场景测试")]
        public void 用户登录の无效号码注销场景()
        {
            WriteLogger("Entering test method {0}", MethodBase.GetCurrentMethod().Name);

            var flag = CtcUtil.TestLogin(new LoginReq
            {
                UserID = 无效号码,
                Action = 注销代码,
            }, WriteLogger);
            Assert.IsFalse(flag, "无效号码用户注销成功！");

            WriteLogger("Leaving test method {0}", MethodBase.GetCurrentMethod().Name);
        }

    }
}
